using System;
using System.Web;
namespace HKB.OnLinePay
{
	public class OnlinePayManege
	{
		public string MerID = "";
		public string MerKey = "";
		public string RetrunUrl = "";
		public string MerContent = "";
		private string _onlinePayType;
		public string _notify_url;
		private string _service;
		private string _out_trade_no;
		private string _subject;
		private string _body;
		private string _payment_type;
		private string _total_fee;
		private string _show_url;
		private string _seller_email;
		private string _seller_id;
		private string _quantity;
		private string _discount;
		private string _buyer_msg;
		private string _buyer_email;
		private string _buyer_id;
		private string _agent;
		private string _receive_name;
		private string _receive_address;
		private string _receive_zip;
		private string _receive_phone;
		private string _receive_mobile;
		private string _logistics_type;
		private string _logistics_fee;
		private string _logistics_payment;
		private string _logistics_type_1;
		private string _logistics_fee_1;
		private string _logistics_payment_1;
		private string _logistics_type_2;
		private string _logistics_fee_2;
		private string _logistics_payment_2;
		public string onlinePayType
		{
			get
			{
				return this._onlinePayType;
			}
			set
			{
				this._onlinePayType = value;
			}
		}
		public bool IsAliPay
		{
			get
			{
				return this.onlinePayType.ToLower() == "alipay";
			}
		}
		public string notify_url
		{
			get
			{
				return this._notify_url;
			}
			set
			{
				this._notify_url = value;
			}
		}
		public string service
		{
			get
			{
				if (this._service == "1")
				{
					if (this.IsAliPay)
					{
						this._service = "trade_create_by_buyer";
					}
				}
				else
				{
					if (this._service == "2")
					{
						if (this.IsAliPay)
						{
							this._service = "trade_create_by_buyer";
						}
					}
					else
					{
						if (this._service == "3")
						{
							if (this.IsAliPay)
							{
								this._service = "user_query";
							}
						}
						else
						{
							if (this._service == "4")
							{
								if (this.IsAliPay)
								{
									this._service = "PAY";
								}
							}
							else
							{
								if (this._service == "5")
								{
									if (this.IsAliPay)
									{
										this._service = "VIEW_DETAIL";
									}
								}
							}
						}
					}
				}
				return this._service;
			}
			set
			{
				this._service = value;
			}
		}
		public string out_trade_no
		{
			get
			{
				return this._out_trade_no;
			}
			set
			{
				this._out_trade_no = value;
			}
		}
		public string subject
		{
			get
			{
				return this._subject;
			}
			set
			{
				this._subject = value;
			}
		}
		public string body
		{
			get
			{
				return this._body;
			}
			set
			{
				this._body = value;
			}
		}
		public string payment_type
		{
			get
			{
				string payment_type;
				if (this.IsAliPay)
				{
					payment_type = this._payment_type;
				}
				else
				{
					payment_type = this._payment_type;
				}
				return payment_type;
			}
			set
			{
				this._payment_type = value;
			}
		}
		public string total_fee
		{
			get
			{
				return this._total_fee;
			}
			set
			{
				this._total_fee = value;
			}
		}
		public string show_url
		{
			get
			{
				return this._show_url;
			}
			set
			{
				this._show_url = value;
			}
		}
		public string seller_email
		{
			get
			{
				return this._seller_email;
			}
			set
			{
				this._seller_email = value;
			}
		}
		public string seller_id
		{
			get
			{
				return this._seller_id;
			}
			set
			{
				this._seller_id = value;
			}
		}
		public string quantity
		{
			get
			{
				return this._quantity;
			}
			set
			{
				this._quantity = value;
			}
		}
		public string discount
		{
			get
			{
				return this._discount;
			}
			set
			{
				this._discount = value;
			}
		}
		public string buyer_msg
		{
			get
			{
				return this._buyer_msg;
			}
			set
			{
				this._buyer_msg = value;
			}
		}
		public string buyer_email
		{
			get
			{
				return this._buyer_email;
			}
			set
			{
				this._buyer_email = value;
			}
		}
		public string buyer_id
		{
			get
			{
				return this._buyer_id;
			}
			set
			{
				this._buyer_id = value;
			}
		}
		public string agent
		{
			get
			{
				return this._agent;
			}
			set
			{
				this._agent = value;
			}
		}
		public string receive_name
		{
			get
			{
				return this._receive_name;
			}
			set
			{
				this._receive_name = value;
			}
		}
		public string receive_address
		{
			get
			{
				return this._receive_address;
			}
			set
			{
				this._receive_address = value;
			}
		}
		public string receive_zip
		{
			get
			{
				return this._receive_zip;
			}
			set
			{
				this._receive_zip = value;
			}
		}
		public string receive_phone
		{
			get
			{
				return this._receive_phone;
			}
			set
			{
				this._receive_phone = value;
			}
		}
		public string receive_mobile
		{
			get
			{
				return this._receive_mobile;
			}
			set
			{
				this._receive_mobile = value;
			}
		}
		public string logistics_type
		{
			get
			{
				return this._logistics_type;
			}
			set
			{
				this._logistics_type = value;
			}
		}
		public string logistics_fee
		{
			get
			{
				return this._logistics_fee;
			}
			set
			{
				this._logistics_fee = value;
			}
		}
		public string logistics_payment
		{
			get
			{
				if (this.IsAliPay)
				{
					if (this._logistics_payment == "1")
					{
						this._logistics_payment = "BUYER_PAY";
					}
					else
					{
						if (this._logistics_payment == "2")
						{
							this._logistics_payment = "SELLER_PAY";
						}
						else
						{
							if (this._logistics_payment == "3")
							{
								this._logistics_payment = "BUYER_PAY_AFTER_RECEIVE";
							}
						}
					}
				}
				return this._logistics_payment;
			}
			set
			{
				this._logistics_payment = value;
			}
		}
		public string logistics_type_1
		{
			get
			{
				return this._logistics_type_1;
			}
			set
			{
				this._logistics_type_1 = value;
			}
		}
		public string logistics_fee_1
		{
			get
			{
				return this._logistics_fee_1;
			}
			set
			{
				this._logistics_fee_1 = value;
			}
		}
		public string logistics_payment_1
		{
			get
			{
				return this._logistics_payment_1;
			}
			set
			{
				this._logistics_payment_1 = value;
			}
		}
		public string logistics_type_2
		{
			get
			{
				return this._logistics_type_2;
			}
			set
			{
				this._logistics_type_2 = value;
			}
		}
		public string logistics_fee_2
		{
			get
			{
				return this._logistics_fee_2;
			}
			set
			{
				this._logistics_fee_2 = value;
			}
		}
		public string logistics_payment_2
		{
			get
			{
				return this._logistics_payment_2;
			}
			set
			{
				this._logistics_payment_2 = value;
			}
		}
		public OnlinePayManege(string gateway)
		{
			this.onlinePayType = gateway;
		}
		public OnlinePayManege()
		{
			this.onlinePayType = "AliPay";
		}
		public void Send()
		{
			string text = "";
			this.onlinePayType = this.onlinePayType.ToLower();
			string onlinePayType = this.onlinePayType;
			if (onlinePayType != null)
			{
				if (!(onlinePayType == "alipay"))
				{
					if (!(onlinePayType == "netbank"))
					{
					}
				}
				else
				{
					AliPay aliPay = new AliPay();
					if (!string.IsNullOrEmpty(this.MerID))
					{
						aliPay.PartnerID = this.MerID;
					}
					if (!string.IsNullOrEmpty(this.MerKey))
					{
						aliPay.Key = this.MerKey;
					}
					if (!string.IsNullOrEmpty(this.RetrunUrl))
					{
						aliPay.return_url = this.RetrunUrl;
					}
					if (!string.IsNullOrEmpty(this.notify_url))
					{
						aliPay.notify_url = this.notify_url;
					}
					text = aliPay.CreatUrl(this.service, this.out_trade_no, this.subject, this.body, this.payment_type, this.total_fee, this.show_url, this.seller_email, this.seller_id, this.quantity, this.discount, this.buyer_msg, this.buyer_email, this.buyer_id, this.agent, this.receive_name, this.receive_address, this.receive_zip, this.receive_phone, this.receive_mobile, this.logistics_type, this.logistics_fee, this.logistics_payment, this.logistics_type_1, this.logistics_fee_1, this.logistics_payment_1, this.logistics_type_2, this.logistics_fee_2, this.logistics_payment_2);
				}
			}
			if (!(text == ""))
			{
				HttpContext.Current.Response.Redirect(text);
			}
		}
	}
}
